package org.dtp;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @ConditionalOnProperty此注解主要为匹配配置中的dtp.enable=true的情况下此配置类为生效状态,未配置也为生效(matchIfMissing=true),具体可参考 <a href="https://www.cnblogs.com/secbro/p/12011522.html"></a>
 */
@Configuration
@ConditionalOnProperty(prefix = "dtp", name = "enable", havingValue = "true", matchIfMissing = true)
/*EnableConfigurationProperties此注解主要为将使用到@ConfigurationProperties 的类注入到Spring容器中 */
@EnableConfigurationProperties(DtpProperties.class)
/*将类交给Spring容器管理,具体可参考https://www.cnblogs.com/yichunguo/p/12122598.html*/
@Import({DtpBeanPostProcessor.class, DtpImportBeanDefinitionRegistrar.class})
public class DtpExecutorAutoConfiguration {

    @Bean
    public NacosListener nacosListener() {
        return new NacosListener();
    }

    @Bean
    public DtpMonitor dtpMonitor() {
        return new DtpMonitor();
    }
}
